package com.gxuwz.restaurant.utils;


import java.util.HashMap;

public class MapUtils<K> extends HashMap<K,Integer> {
    /**
     * 使用HashMap中containsKey判断key是否已经存在
     * @param key
     * @param value
     * @return
     */
    public Integer put(K key, Integer value) {
        Integer newV = value;
        if (containsKey(key)) {
            Integer oldV = get(key);
            newV = oldV + newV;
        }
        return super.put(key, Integer.valueOf(newV));
    }

}
